<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCouponActivesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupon_actives', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title')->comment('活动名称');
            $table->string('summary')->nullable()->comment('活动说明');

            $table->integer('limit')->default(0)->comment('优惠卷发放限额，0表示无限制。');
            $table->integer('released')->default(0)->comment('优惠卷已发放的数量');
            $table->integer('used')->default(0)->comment('已使用的数量');

            $table->integer('type')->default(0)->comment('优惠卷类型 0：无优惠； 1：特价；2：折扣；3：满减；4：买赠');
            $table->string('param')->nullable()->comment('优惠卷参数 JSON');
            $table->string('available_merchants')->nullable()->comment('适用的商户 JSON');
            $table->string('available_categories')->nullable()->comment('适用的商品分类 JSON');
            $table->string('available_goods')->nullable()->comment('适用的商品范围 JSON');
            $table->string('available_members')->nullable()->comment('适用的用户 JSON');

            $table->timestamp('start_at')->nullable()->comment('活动开始时间');
            $table->timestamp('end_at')->nullable()->comment('活动结束时间');           
            $table->integer('status')->default(0)->comment('状态 0：下架，1：发布 。');

            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('coupon_actives');
    }
}
